'''
Created on Apr 24, 2013

@author: wdoering
'''
import time
import Tkinter, datetime, thread
class ListFile(object):
    
    def __init__(self,fileTimestamp,fileName,locktimeout):
        self.fileTimestamp = fileTimestamp
        self.fileName = fileName
        self.locktimeout = locktimeout
        self.isFileLocked = False
        self.present = True
    def isUnlocked(self):
        return self.isFileLocked
    def lock(self):
        self.isFileLocked = True
        thread.start_new_thread(self.lockTimeout, (self.locktimeout,))
    def unlock(self):
        self.unlock()
    def getFileName(self):
        return self.fileName
    def getTimestamp(self):
        return self.fileTimestamp
    def setTimestamp(self, t):
        self.fileTimestamp = t 
    def isPresent(self):
        return self.present
    def notPresent(self):
        self.present = False
        
    def __eq__(self, other):
        if self.fileName == other.getFileName():
            return True
        else:
            return False   
        
    def lockTimeout(self, t):
        time.sleep(t)
        self.unlock()